﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;


namespace HMViewerWCFServices
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    public class Service1 : IService1
    {
        private HoldemManagerDAL.EFEntity context;
        //initialising the data connection
        public Service1()
        {
            context = new HoldemManagerDAL.EFEntity();
        }
        public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }


        public CompositeType GetDataUsingDataContract(CompositeType composite)
        {
            if (composite == null)
            {
                throw new ArgumentNullException("composite");
            }
            if (composite.BoolValue)
            {
                composite.StringValue += "Suffix";
            }
            return composite;
        }

        /// <summary>
        /// Liste des sites gérés par HoldemManager
        /// </summary>
        /// <returns></returns>
        public List<HoldemManagerDAL.DTO.pokersites> GetPokerSites()
        {
            return context.GetPokerSites();
        }

        /// <summary>
        /// Un Site par son ID
        /// </summary>
        /// <returns></returns>
        public HoldemManagerDAL.DTO.pokersites GetPokerSiteById(int Id)
        {
            return context.GetPokerSiteById(Id);
        }


        /// <summary>
        /// Un Site par son Abreviation
        /// </summary>
        /// <returns></returns>
        public HoldemManagerDAL.DTO.pokersites GetPokerSite(HoldemManagerDAL.EFEntity.PokerSitesAbrev Abrev)
        {
            return context.GetPokerSite(Abrev);
        }

        /// <summary>
        ///Les tables actives pour un site
        /// </summary>
        /// <returns></returns>
        public List<HoldemManagerDAL.DTO.tables> GetActiveTables(Int32 IdSite)
        {
            return context.GetActiveTables(IdSite);
        }

        /// <summary>
        /// Retourne un utilisateur par son ID
        /// </summary>
        /// <returns></returns>
        public HoldemManagerDAL.DTO.players GetPlayerById(Int32 Id)
        {
            return context.GetPlayerById(Id);
        }

         /// <summary>
        /// Retourne la liste des joeurs "signifiants" pour un site
        /// </summary>
        /// <returns></returns>
        public List<HoldemManagerDAL.DTO.players> GetPokerSitePlayers(Int32 IdSite)
        {
            return context.GetPokerSitePlayers1(IdSite);

            
        }


        /// <summary>
        /// Retourne les mains des dernières sessions actives
        /// </summary>
        /// <returns></returns>
        public List<HoldemManagerDAL.pokerhands > GetActiveHands(Int32 IdSite)
        {
            return context.GetActiveHands(IdSite);
        }

        /// <summary>
        /// Retourne les mains des dernières sessions actives pour le joeurs selcetionné
        /// </summary>
        /// <returns></returns>
        public List<HoldemManagerDAL.playerhandscashkeycolumns> GetHandsActiveHands(Int32 IdPlayer)
        {
            return context.GetHandsActiveHands(IdPlayer).OrderByDescending(h=>h.handtimestamp)  .ToList();
        }


          /// <summary>
        /// Retourne la liste des joueurs pour site
        /// </summary>
        /// <param SiteName>Le nomd du site</param>
        /// <returns>La liste des joueurs d'un site ayany un nombre de main suffisante</returns>
        public List<HoldemManagerDAL.DTO.players> GetPokerSitePlayersByName(string SiteName)
        {
            return context.GetPokerSitePlayersByName(SiteName);
        }

        ///// <summary>
        ///// returne the revelant player list on PokerStar
        ///// </summary>
        ///// <returns></returns>
        //public List<HoldemManagerDAL.DTO.players> GetPokerStarsRevelantPlayers()
        //{
        //   // return context.GetPokerStarsRevelantPlayers();
        //}

    }
}
